home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 2.6 KB | 104 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSOMEnv.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWSOMENV_H
- #define FWSOMENV_H
-
- #ifndef FWENVDEF_H
- #include "FWEnvDef.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #include <som.xh>
-
- //========================================================================================
- // CLASS FW_SOMEnvironment
- //
- // This class is used instead of Environment *. It creates a stack-local Environment
- // (thereby being threadsafe) and constructs/destructs it. It overloads "operator->()"
- // to provide access to the fields of the underlying Environment. It also contains
- // "operator Environment* ()" so that it can be passed to SOM methods
- //
- // Usage:
- //
- // void foo(FW_SOMThing *aSOMThing)
- // {
- // FW_SOMEnvironment ev;
- // aSOMThing->KerSplashMethod(ev);
- // }
- //========================================================================================
-
-
-
- class FW_SOMEnvironment
- {
- public:
- // FW_DECLARE_AUTO(FW_SOMEnvironment)
-
- FW_SOMEnvironment();
- ~FW_SOMEnvironment();
-
- Environment* operator->();
- operator Environment*();
-
- private:
- Environment fev;
- };
-
-
- //----------------------------------------------------------------------------------------
- // FW_SOMEnvironment::FW_SOMEnvironment
- //----------------------------------------------------------------------------------------
-
- inline FW_SOMEnvironment::FW_SOMEnvironment()
- {
- // SOM_InitEnvironment(&fev);
- FW_PrimitiveSetMemory(&fev, sizeof(Environment), 0);
- // FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_SOMEnvironment::~FW_SOMEnvironment
- //----------------------------------------------------------------------------------------
-
- inline FW_SOMEnvironment::~FW_SOMEnvironment()
- {
- // FW_START_DESTRUCTOR
- // SOM_UninitEnvironment(&fev);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_SOMEnvironment::operator->
- //----------------------------------------------------------------------------------------
-
- inline Environment* FW_SOMEnvironment::operator->()
- {
- return &fev;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_SOMEnvironment::~FW_SOMEnvironment
- //----------------------------------------------------------------------------------------
-
- inline FW_SOMEnvironment::operator Environment*()
- {
- return &fev;
- }
-
-
- #endif
-
-
-